//@author A0080384E
/*
Session Manager manages the input and output of the virtual repository to a .txt file. 
It is called by Logic when the programme is first started to initialize and populate the Storage component. 
This is achieved by reading the .txt file and calling the TaskManager and Storage components to execute it. 
It is also called by Logic to save the current session to the .txt file when either user calls 
the save command or at the end of each session. 
*/

#ifndef SESSION_MANAGER_H
#define SESSION_MANAGER_H

#include "Logger.h"
#include "Task.h"
#include <vector>
#include <sstream>
#include <fstream>
#include <istream>
#include <QDir>
#include <string>

using namespace std;

#define FILE_NAME "toggletask.txt"
#define TOGGLETASK_DIR "C:/toggletask"
#define MESSAGE_FILE_CREATED "toggletask directory created at: C:/toggletask"
#define MESSAGE_SESSION_LOADED "Previous session loaded. Here are your upcoming tasks: "
#define DELIMITER "/"
#define COMPLETE_CHAR "*"
#define SPACE " "

class SessionManager {
public:
    bool isSession(QString &userFeedback, ostringstream &readFile);
    void storeThisSession(QVector<Task> taskList);
    ostringstream loadLastSession(QString fileName);

	SessionManager();

private:
    ofstream saveTask;
    ifstream loadTask;
	Logger logger;

    QString createFile(QString fileName);

};

#endif
